using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using SMMSApp.Entities;

namespace SMMSApp.BLL
{
    class Student
    {
        string sqlInsert="INSERT INTO student(studentid, classid, studentname,birthday, address, phone, email)"
           + " VALUES(@studentid,@classid,@studentname,@birthday,@address,@phone,@email)";

        public int addStudent(StudentInfo st)
        {
            int i = 0;
            try
            {
                SqlParameter[] parms = new SqlParameter[]{
                    new SqlParameter("@studentid",SqlDbType.Char),
                    new SqlParameter("@classid",SqlDbType.Char),
                    new SqlParameter("@studentname",SqlDbType.NVarChar),
                    new SqlParameter("@birthday",SqlDbType.DateTime),
                    new SqlParameter("@address",SqlDbType.NVarChar),
                    new SqlParameter("@phone",SqlDbType.Char),
                    new SqlParameter("@email",SqlDbType.Char)};
                parms[0].Value = st.StudentID;
                parms[1].Value = st.ClassID;
                parms[2].Value = st.StudentName;
                parms[3].Value = st.BirthDay;
                parms[4].Value = st.Address;
                parms[5].Value = st.Phone;
                parms[6].Value = st.Email;
                i = SQLHelper.executeNonQuery(SQLHelper.STRCONN, CommandType.Text, sqlInsert, parms);
                return i;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }

    }
}
